package com.zhangtong.excel.generator;

import com.zhangtong.excel.ExcelContext;
import com.zhangtong.excel.entity.ProjectWorktimeData;
import com.zhangtong.excel.entity.StatisticsData;
import com.zhangtong.excel.entity.Title;
import org.apache.poi.ss.usermodel.Row;

import java.util.TreeMap;

public class ProjectGenerator implements IGenerator {

    @Override
    public void generateRows(StatisticsData statisticsData, Title title, ExcelContext context) {
        TreeMap<String, ProjectWorktimeData> data = statisticsData.getProjectStatistics();
        data.forEach((project, worktimeData) -> {
            Row row = context.createNextRow();
            IGenerator.generateCells(null, project, worktimeData.getTotalWorktime(), title, row, context);
        });
    }
}
